<small>
 <script type="text/javascript" src="/js/bootstrap-datetimepicker.min.js"></script>
 <script type="text/javascript" src="/js/DatePicker/WdatePicker.js" ></script>
<div class="row"> 
  <div class="span3 bs-docs-sidebar "> <*include file="<*$controller*>/location.tpl"*></div>
 <div class="span8"> 
      <form class="form-horizontal" id="regform" name="regform" action="/<*$controller*>/opcoupon" method="post" onsubmit="return checkLoginForm();">
        <div class="control-group">
          <label class="control-label" for="inputEmail"><strong>优惠券说明</strong></label>
          <div class="controls">
            <input type="text" id="description" name="description" placeholder="说明">
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="inputPassword"><strong>服务类型</strong></label>
          <div class="controls">
            <label class="checkbox inline">
  				  <input type="checkbox" name="options[]" id="base" value="base"> 基础服务
 		   </label>
           
           <label class="checkbox inline">
  				  <input type="checkbox" name="options[]" id="album" value="album"> 相册
 		   </label>
           
           <label class="checkbox inline">
  				  <input type="checkbox" name="options[]" id="courseware" value="courseware" > 课件下载
 		   </label>  
           
           <label class="checkbox inline">
  				  <input type="checkbox" name="options[]" id="free" value="free" > 免费充值
 		   </label> 
          </div> 
        </div> 
        
        <div class="control-group">
          <label class="control-label" for="inputEmail"><strong>优惠券购买价格</strong></label>
          <div class="controls">
            <input type="text" id="buy_price" class="input-small" name="buy_price" placeholder="0表示免费"> 元
          </div>
        </div>  
        
        <div class="control-group">
          <label class="control-label" for="到期时间"><strong>到期时间</strong></label>
          <div class="controls" >
            <div class="input-append"  >
            <input type="text" name="expiry" id="expiry"  class="input-small" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" language="UTF-8" ></input>
            <span class="add-on">
                 <i data-time-icon="icon-time" class="icon-calendar">
                 </i>
             </span>
             </div>
           </div>
	    </div>
        
        
        <div class="control-group">
          <label class="control-label" for="inputEmail"><strong>消费金额必需满足多少钱</strong></label>
          <div class="controls">  
               <input type="text" name="money_max" class="input-small" id="money_max"  placeholder="" >元 （比如：满200元减20元） 
          </div>
        </div> 
        
         <div class="control-group">
          <label class="control-label" for="inputEmail"><strong>优惠的金额</strong></label>
          <div class="controls">  
               <input type="text" name="money_reduce" class="input-small" id="money_reduce"  placeholder="" >元  
          </div>
        </div> 
        
      <div class="control-group">
          <label class="control-label" for="inputEmail"><strong>优惠券类型</strong></label>
          <div class="controls">
             <label class="radio inline">
                <input type="radio" name="optionsRadios" id="gold" value="gold"  onclick="alter(this.value)" >
              抵用金
            </label> 
            <label class="radio inline">
              <input type="radio" name="optionsRadios" id="dicount" value="discount"  onclick="alter(this.value)">
             折扣
            </label> 
          </div>
        </div> 
        
        <div id="AllowDiv" >
               
        </div>  
         <div class="control-group">
          <label class="control-label" for="inputEmail"><strong>数量</strong></label>
          <div class="controls">
            <input type="text" id="amount" name="amount" placeholder="数量">
          </div>
        </div>   
        <div class="control-group">
          <label class="control-label" for="inputEmail"><strong>优惠券领取数量限制</strong></label>
          <div class="controls">
               <label class="checkbox inline">
                      <input type="checkbox" name="receive_limit" id="receive_limit" value="1" > 每个账户只能领取一次
               </label>   
          </div>
        </div>   
       
        <div class="control-group">
          <div class="controls"> 
              <button class="btn btn-large   btn-primary" type="submit">生成优惠券</button>
              <button class="btn btn-large" onClick="history.back();" type="button" >返回</button>
          </div>
        </div>  
      </form>
     </div> 
</div>
<script type="text/javascript">
 
 
function  alter(a){
	  
	 if(a=='gold'){
	   //显示面值 数量的信息	
	    document.getElementById('AllowDiv').innerHTML = '<div class="control-group"><label class="control-label" for="inputEmail"><strong>面值</strong></label><div class="controls"><input type="text" id="price" name="price" placeholder="面值">元</div></div>';  
	  }else if(a=='discount'){  
	    document.getElementById('AllowDiv').innerHTML = '<div class="control-group"><label class="control-label" for="inputEmail"><strong>折扣</strong></label><div class="controls"><input type="text"  class="input-small" id="discount" name="discount" placeholder="输入数字">%（比如：100%）</div></div>'; 
	  } 
	
	}
  
function checkLoginForm(){
	var ammount=document.getElementById('description').value; 
	if(ammount=='' || ammount==null){ 
	      alert('请填写优惠券的说明');
		document.getElementById("description").focus();
		return false;
	} 
	
	 var  list = document.getElementsByName("options[]");  
     var  typelist='';
	  for( i =0 ; i<list.length; i++ )
  		{  
			if( list[i].checked==true ){
				 var  typelist=i+1;
				 } 
  		}  
	if(typelist=='' || typelist==null){
		alert('请填写优惠券的服务类型'); 
		return false;
	}  
	//优惠券是否满意
	var buy_price=document.getElementById('buy_price').value; 
	if(buy_price=='' || buy_price==null){ 
	      alert('请写优惠券的价格');
		document.getElementById("buy_price").focus();
		return false;
	} 
	
	var expiry=document.getElementById('expiry').value; 
	 
	if(expiry=='' || expiry==null){ 
	      alert('请写优惠券的价格');
	  document.getElementById("expiry").focus();
		return false;
	} 
	
	var money_max=document.getElementById('money_max').value; 
	
	if(money_max=='' || money_max==null){ 
	      alert('优惠券使用需要满足的金额');
	  document.getElementById("money_max").focus();
		return false;
	} 
	
	var money_reduce=document.getElementById('money_reduce').value; 
	
	if(money_reduce=='' || money_reduce==null){ 
	      alert('使用优惠券的优惠金额');
	  document.getElementById("money_reduce").focus();
		return false;
	} 
	
	return true;
}

</script>
</small> 